package com.itheima.controller;

import com.itheima.anno.Log;
import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.Dept;
import com.itheima.pojo.Emp;
import com.itheima.pojo.Result;
import com.itheima.service.DeptService;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 部门管理Controller
 */
@RestController
public class DeptController {

    @Autowired
    private DeptService deptService;

    @Autowired
    private EmpMapper empMapper;

    @Log
    @GetMapping("/depts")
    public Result xx() {
        List<Dept> depts = deptService.xx();
        return Result.success(depts);
    }

    @Log
    @PostMapping("/depts")
    public Result tj(@RequestBody Dept dept) {
        deptService.tj(dept);

        return Result.success();

    }

    @Log
    @DeleteMapping("/depts/{id}")
    public Result sc(@PathVariable Integer id){
        deptService.sc(id);
        empMapper.sc(id);

        return Result.success();
    }

}
